<!DOCTYPE html>
<html lang="zh_CN">
<head>
	<meta charset="UTF-8">
	<title></title>
</head>
<body>
<p>Original content</p>
<script>
	var xhr = new XMLHttpRequest();
	//指定请求属性
	xhr.open('GET', 'http://localhost' + window.location.pathname, true);
	document.write('http://localhost' + window.location.pathname);
	//定义回调函数
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4) {
			var message = '';
			if(xhr.status == 200) {
				message = 'Ajax loaded content' ;
			} else {
				message = 'An error has occured making the request';
			}

			document.getElementsByTagName('p')[0].innerHTML = message;
		}
	};
	//发送实际的请求
	xhr.send();
</script>
</body>
</html>